<div class="popup_body">
    <div class="search">
        <div class="float_right">
            <button class="btn btn_yellow" id="query_${pid}">搜索</button>
        </div>
        <table cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td align="right" width="80">电池编号：</td>
                <td><input type="text" class="text" id="id" onkeyup="query()"/></td>
                <td align="right" width="80">外壳编号：</td>
                <td><input type="text" class="text" id="shellCode" onkeyup="query()"/></td>
            </tr>
        </table>
    </div>
    <div style="width:800px; height:360px; padding-top: 6px;">
        <table id="page_table_${pid}">
        </table>
    </div>
</div>
<div class="popup_btn">
    <button class="btn btn_border" id="close_${pid}">关闭</button>
</div>
<script>
    (function() {
        var win = $('#${pid}'), windowData = win.data('windowData');
        var datagrid = $('#page_table_${pid}');
        datagrid.datagrid({
            fit: true,
            width: '100%',
            height: '100%',
            striped: true,
            pagination: true,
            url: "${contextPath}/security/hdw/battery/page.htm",
            fitColumns: true,
            pageSize: 10,
            pageList: [10, 50, 100],
            idField: 'id',
            singleSelect: true,
            selectOnCheck: false,
            checkOnSelect: false,
            autoRowHeight: false,
            rowStyler: gridRowStyler,
            columns: [
                [
                    {
                        title: '电池编号',
                        align: 'center',
                        field: 'id',
                        width: 60
                    },
                    {
                        title: '外壳编号',
                        align: 'center',
                        field: 'shellCode',
                        width: 60
                    },
                    {
                        title: '刷新时间',
                        align: 'center',
                        field: 'refreshTime',
                        width: 60
                    }
                ]
            ],
            onLoadSuccess:function() {
                datagrid.datagrid('clearChecked');
                datagrid.datagrid('clearSelections');
            },onClickRow:  function(rowIndex, rowData) {
                select_${pid}(rowData.id);
            }
        });
    })();

    var win = $('#${pid}'), windowData = win.data('windowData');
    var datagrid = $('#page_table_${pid}');
    function select_${pid}() {
        var battery = datagrid.datagrid('getSelected');
        if(battery) {
            windowData.ok({
                battery: battery
            });
            win.window('close');
        } else {
            $.messager.alert('提示信息', '请选择一个电池');
        }
    }

    $('#close_${pid}').click(function() {
        $('#${pid}').window('close');
    });
    $('#query_${pid}').click(function() {
        query();
    });

    function query() {
        datagrid.datagrid('options').queryParams = {
            id: $('#id').val(),
            shellCode: $('#shellCode').val()
        };
        datagrid.datagrid('load');
    }
</script>

